package com.huang.viewpage;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager2.widget.ViewPager2;

import com.clovsoft.banner.ViewPagerAdapter;
import com.viewpagerindicator.CirclePageIndicator;
import com.viewpagerindicator.TitlePageIndicator;

import java.util.ArrayList;
import java.util.List;

public class MainActivity3 extends AppCompatActivity {
    List<Fragment> fragmentList = new ArrayList<Fragment>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);

        initFragment();
        //Set the pager with an adapter
//        ViewPager2 pager = findViewById(R.id.view_pager);
        ViewPager pager = findViewById(R.id.view_pager);
//        ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(), getLifecycle(), fragmentList);
        //Bind the title indicator to the adapter

        pager.setAdapter(new TestAdapter(getSupportFragmentManager(),fragmentList));
        DotIndicator2 dotIndicator = findViewById(R.id.tab_layout);
//        dotIndicator.setViewPager2(pager);
        dotIndicator.setViewPager(pager);


    }
    private void initFragment() {
        fragmentList.add(new FirstFragment());
        fragmentList.add(new SecondFragment());
        fragmentList.add(new ThirdFragment());
        fragmentList.add(new FirstFragment());
        fragmentList.add(new SecondFragment());
        fragmentList.add(new ThirdFragment());
    }

}